<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // 创建ajax对象
    var xhr = new XMLHttpRequest();
    //配置ajax对象
    xhr.open('get','http://localhost:3000/responseData');
    //发送请求
    xhr.send();
    //获取响应数据
    xhr.onload = function () {
        const responseText = JSON.parse(xhr.responseText);
        console.log(responseText);
        var str = '<h2>'+ responseText.name+'</h2>'
        document.body.innerHTML = str;
    }
</script>
</body>
</html>